//package com.ctrip.frame;
//
//import com.rfca.business.MessageQueue;
//import com.rfca.business.MessageService;
//import com.rfca.vo.CallMessage;
//
//import javax.swing.*;
//import java.awt.*;
//import java.net.URL;
//
//public class MyListCellRenderer implements ListCellRenderer<CallMessage> {
//    private static final URL UNREAD_IMG = MainFrame.class.getClassLoader().getResource("images/notify.png");
//    private static final URL READED_IMG = MainFrame.class.getClassLoader().getResource("images/msg.png");
////    public MyListCellRenderer(LayoutManager layout, boolean isDoubleBuffered) {
////        super(layout, isDoubleBuffered);
////    }
////
////    public MyListCellRenderer(LayoutManager layout) {
////        super(layout);
////    }
////
////    public MyListCellRenderer(boolean isDoubleBuffered) {
////        super(isDoubleBuffered);
////    }
////
////    public MyListCellRenderer() {
////        super();
////        setOpaque(true);
////    }
//
//    @Override
//    public Component getListCellRendererComponent(JList list, CallMessage value, int index, boolean isSelected, boolean cellHasFocus) {
////        JLabel label = new JLabel("asdfasdf");
////        JLabel label2 = new JLabel("hello");
////        JPanel panel = new JPanel();
////        panel.add(label);
////        panel.add(label2);
////        return panel;
//        CallMessage message = value;
////        this.setSize(352, 33);
//        Icon icon;
//        if (message.getHandleState().equals(0) && !isSelected) {
//            icon = new ImageIcon(UNREAD_IMG);
//        } else {
//            icon = new ImageIcon(READED_IMG);
//        }
//        JLabel labelIcon = new JLabel(icon, JLabel.LEFT);
//        labelIcon.setSize(30, 32);
//        JLabel sender = new JLabel(message.getSender());
//        sender.setPreferredSize(new Dimension(50, 32));
//        sender.setFont(new Font(Theme.fontFamily, Font.BOLD, 12));
//        sender.setHorizontalAlignment(JLabel.LEFT);
//
//        JLabel sendTime = new JLabel(message.getSendTime());
//        sendTime.setPreferredSize(new Dimension(70, 32));
//        sendTime.setFont(new Font(Theme.fontFamily, Font.PLAIN, 12));
//        sendTime.setHorizontalAlignment(JLabel.LEFT);
//        sendTime.setForeground(Color.GRAY);
//
//        JLabel msgBody = new JLabel(message.getMessage());
//        msgBody.setFont(new Font(Theme.fontFamily, Font.BOLD, 15));
//        msgBody.setPreferredSize(new Dimension(80, 32));
//        msgBody.setForeground(new Color(136, 72, 152));
//        msgBody.setHorizontalAlignment(JLabel.LEFT);
//
//        JLabel location = new JLabel(message.getLocation());
//        location.setPreferredSize(new Dimension(165, 32));
//        location.setFont(new Font(Theme.fontFamily, Font.PLAIN, 15));
//        location.setHorizontalAlignment(JLabel.LEFT);
//        location.setForeground(Color.GRAY);
////        location.setHorizontalAlignment(JLabel.RIGHT);
//
////        StringBuilder sb = new StringBuilder("<html>");
//
////        JPanel line1 = new JPanel();
////        line1.setSize(400,28);
////
////        JPanel line2 = new JPanel();
////        line2.setSize(400,18);
////        GridLayout gridLayout = new GridLayout(2,2);
////        gridLayout.set
////        block.setLayout(new SpringLayout());
////        block.setOpaque(true);
////        line1.add(sender);
////        line1.add(msgBody);
////
////        line2.add(location);
////        line2.add(sendTime);
////        msgBody.setSize(400, 50);
////        JPanel block = new JPanel();
////
////        block.add(sender);
////        block.add(msgBody);
////        block.add(location);
////        block.add(sendTime);
//
//        JPanel panel = new JPanel();
//
////        GridBagLayout gridBagLayout = new GridBagLayout();
////        block.setLayout(gridBagLayout);
////        block.setSize(400, 80);
//
////        block.add(sender,new GBC(0,0,1,1)
//////                .setIpad(0, 50)
////                .setWeight(40, 60)
////                .setAnchor(GBC.WEST)
////                .setFill(GBC.HORIZONTAL)
////                .setInsets(0,1,0,10));
////
////        block.add(sendTime,new GBC(1,0,1,1)
//////                .setIpad(0, 50)
////                .setWeight(60,60)
////                .setAnchor(GBC.EAST)
////                .setFill(GBC.HORIZONTAL)
////                .setInsets(0,250,0,5));
////        block.add(msgBody,new GBC(0,1,1,1)
//////                .setIpad(0, 50)
////                .setWeight(40, 40)
////                .setAnchor(GBC.WEST)
////                .setFill(GBC.HORIZONTAL)
////                .setInsets(0,1,0,10));
////        block.add(location,new GBC(1,1,1,1)
//////                .setIpad(0, 50)
////                .setWeight(60, 40)
////                .setAnchor(GBC.EAST)
////                .setFill(GBC.HORIZONTAL)
////                .setInsets(0,250,0,5));
//        if (isSelected) {
//            panel.setBackground(new Color(213, 237, 254));
//            if (message.getHandleState().equals(0)) {
//                MessageQueue.handle(message.getId());
//                MessageService.handle(message.getId());
//            }
//        } else {
//            panel.setBackground(new Color(245, 249, 255));
//        }
//        panel.setLayout(new FlowLayout(FlowLayout.LEFT));
//        panel.add(labelIcon);
////        panel.add(block);
//        panel.add(sender);
//        panel.add(msgBody);
//        panel.add(location);
//        panel.add(sendTime);
////        block.setBackground(block.getParent().getBackground());
//
//        panel.setBorder(BorderFactory.createEtchedBorder());
//
//        //debug
////        line1.setBorder(BorderFactory.createLineBorder(Color.RED));
////        line2.setBorder(BorderFactory.createLineBorder(Color.RED));
//
////        panel.setOpaque(true);
//        return panel;
//    }
//
//}
